 package com.suozq.nio;

import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

/**
 * @author 锁战强
 * @date 2022/04/06
 */
public class FileChannelTransfer {
    public static void main(String[] args) {
        try(FileChannel inChannel = FileChannel.open(Paths.get("G:/test.txt"),StandardOpenOption.READ);
            FileChannel outChannel = FileChannel.open(Paths.get("G:/testC.txt"),StandardOpenOption.WRITE,StandardOpenOption.CREATE)) {
            outChannel.transferFrom(inChannel, 0, inChannel.size());
            System.out.println("传输完成");
        } catch (IOException e) {
             e.printStackTrace();
        }
            
    }
}
